// pages/presentRecord/presentRecord.js
var app = getApp();
Page({

  /**
   * 页面的初始数据
   */
  data: {
    page: 1,
    page_count: 1,
    noMore: false,
    row: 8,
    detailedList: []
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    var that = this;
    that.applicationCashList();
  },



  reachBottom: function () {
    var that = this;
    var page = that.data.page + 1;
    if (page > that.data.page_count) {
      that.setData({
        noMore: true
      })
      return false;
    }
    that.setData({
      page: page
    })
    that.applicationCashList();
  },

  applicationCashList: function () {
    var that = this;
    that.setData({
      loadingHidden: false
    })
    app.ajax({
      url: "Salesman/Account/withdrawApply",
      data: {
        page: that.data.page,
        row: that.data.row,
      },
      success: function (res) {
        var list = that.data.detailedList.concat(res.data.data.data)
        var len = res.data.data.data.length;
        if (res.data.code == 1000) {

          if (that.data.row > len) {
            that.setData({
              noMore: true
            })
          } else {
            that.setData({
              noMore: false
            })
          }

          that.setData({
            detailedList: list,
            page_count: res.data.data.page.total_page,
            empty: res.data.data.page.total_page == 0 ? true : false
          })

        }
        // if (res.data.data.data.length == 0) {
        //   app.showToast('没有更多了');
        // }
      }
    })
  },
})